package cn.boy.service;

import java.io.InputStream;
import java.util.Properties;

import cn.boy.dao.StudentDao;
import cn.boy.dao.StudentDaoFactory;

public class StudentServiceFactory {
	
	private StudentService service;
	private static StudentServiceFactory instance = new StudentServiceFactory();

	private StudentServiceFactory() {

		try {
			Properties prop = new Properties();
			InputStream is = StudentDaoFactory.class.getClassLoader()
					.getResourceAsStream("config.properties");
			prop.load(is);
			String studentServiceClass = prop.getProperty("studentServiceClass");
			Class clazz = Class.forName(studentServiceClass);
			service = (StudentService) clazz.newInstance();
		} catch (Exception e) {
			e.printStackTrace();
			throw new ExceptionInInitializerError(e);
		}

	}

	public static StudentServiceFactory getInstance() {
		return instance;
	}

	public StudentService getStudentService() {
		return service;
	}

}
